#ifndef VETOR2D_H
#define VETOR2D_H

#include <cmath>

struct Vetor2d
{
   Vetor2d(void);
   Vetor2d(float xy);
   Vetor2d(float x, float y);

   static Vetor2d fromAngle( float angle )
   {
	   return Vetor2d( -::sin(angle*M_PI/180.0), ::cos(angle*M_PI/180.0) );
   }

#define IMPLEMENT_BINARY_OPERATOR( op )         \
    Vetor2d operator op(const Vetor2d& v) const \
   {                                            \
       return Vetor2d(x op v.x, y op v.y);      \
   }

#define IMPLEMENT_BINARY_SCALAR_OPERATOR( op )    \
    Vetor2d operator op(float scalar) const       \
   {                                              \
       return Vetor2d(x op scalar, y op scalar);  \
   }

#define IMPLEMENT_SELF_OPERATOR( op )             \
    Vetor2d& operator op(const Vetor2d& v)        \
   {                                              \
       x op v.x;                                  \
       y op v.y;                                  \
       return *this;                              \
   }

#define IMPLEMENT_SELF_SCALAR_OPERATOR( op )       \
    Vetor2d& operator op(float scalar)             \
   {                                               \
       x op scalar;                                \
       y op scalar;                                \
       return *this;                               \
   }

    IMPLEMENT_BINARY_OPERATOR(+)
    IMPLEMENT_BINARY_OPERATOR(-)
    IMPLEMENT_BINARY_OPERATOR(/)
    IMPLEMENT_BINARY_OPERATOR(*)

    IMPLEMENT_SELF_OPERATOR(+=)
    IMPLEMENT_SELF_OPERATOR(-=)
    IMPLEMENT_SELF_OPERATOR(*=)
    IMPLEMENT_SELF_OPERATOR(/=)

    IMPLEMENT_BINARY_SCALAR_OPERATOR(*)
    IMPLEMENT_BINARY_SCALAR_OPERATOR(/)

    IMPLEMENT_SELF_SCALAR_OPERATOR(*=)
    IMPLEMENT_SELF_SCALAR_OPERATOR(/=)

/*
   Vetor2d operator+(const Vetor2d& v) const
   {
       return Vetor2d(x + v.x, y+ v.y);
   }*/

    // ...
   float x, y;
};


#endif // VETOR2D_H
